package cn.zn.modules.money.cur.controller;

import cn.zn.framework.common.utils.R;
import cn.zn.framework.common.validator.group.AddGroup;
import cn.zn.framework.common.validator.group.UpdateGroup;
import cn.zn.modules.money.cur.entity.dto.TMoneyInfoDetailFreezeDTO;
import cn.zn.modules.money.cur.service.TMoneyInfoDetailFreezsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("money/cur/moneyinfodetailfreezs")
public class TMoneyInfoDetailFreezsController {

    @Autowired
    private TMoneyInfoDetailFreezsService tMoneyInfoDetailFreezsService;

    @PostMapping("save")
    public void save(@Validated({AddGroup.class}) @RequestBody TMoneyInfoDetailFreezeDTO dto) {
        tMoneyInfoDetailFreezsService.save(dto);
    }

    @PostMapping("update")
    public void update(@Validated({UpdateGroup.class}) @RequestBody TMoneyInfoDetailFreezeDTO dto) {
        tMoneyInfoDetailFreezsService.update(dto);
    }

    @PostMapping("apply/{moneyInfoId}")
    public R info(@PathVariable String moneyInfoId, @RequestBody Map<String, Object> params) {
        return R.ok().put("list", tMoneyInfoDetailFreezsService.queryFreezsApply(moneyInfoId, params));
    }

    @DeleteMapping("delete")
    public void delete(@RequestBody String[] ids) {
        tMoneyInfoDetailFreezsService.delete(ids[0]);
    }

}
